cmake_minimum_required(VERSION 3.20)

# 设置项目名称
project(FileSystem
        LANGUAGES CXX
        VERSION 0.1.0)

# 添加共享库
add_library(${PROJECT_NAME} SHARED ./SGFileSystem.cpp)

target_link_libraries(${PROJECT_NAME} PRIVATE Exception)

# 预定义宏
target_compile_definitions(${PROJECT_NAME} PRIVATE EXPORTING_FileSystem)

import_json()

# Boost库
find_package(Boost REQUIRED COMPONENTS filesystem)

target_link_libraries(${PROJECT_NAME} PRIVATE Boost::boost Boost::filesystem)

# Header files install
install(
  DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  DESTINATION include/Utility
  FILES_MATCHING
  PATTERN "*.h"
  PATTERN "UnitTest" EXCLUDE)
  
# 安装目标
install(
  TARGETS ${PROJECT_NAME}
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin)

# 添加单元测试子项目
if(SG_BUILD_UNIT_TEST)
    add_subdirectory(UnitTest)
endif()